﻿using BwTMusicHelper;
using BwTMusicModels;
using BwTMusicServices.Music;
using BwTMusicServices.Order;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace BwTMusic.Controllers
{
    public class CarController : Controller
    {
        OrderServices order = new OrderServices();
        MusicServices music = new MusicServices();
        // GET: Car
        public ActionResult BuyCar()
        {
            return View();
        }
        public JsonResult CustomerOrder(string CustomerName,string OrderNote,List<orderHelper> ids)
        {
            List<string> strs = new List<string>();
            for (int i = 0; i < ids.Count; i++)
            {
                music.AddMusicChooseCount(ids[i].id);
                strs.Add(ids[i].id.ToString());
            }
            string str = string.Join(",", strs.ToArray());
            North_Order _order = new North_Order();
            _order.OrderNote = OrderNote;
            _order.OrderCustomer = CustomerName;
            _order.OrderTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            _order.OrderItem = str;
            return Json(new { data = order.AddAOrderInfo(_order, out Guid key), message = "提交成功", key = key }, JsonRequestBehavior.AllowGet);
        }
    }
}